﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Theme_3_UserControls_WebVisitNum : System.Web.UI.UserControl
{
    PowerCreator.LMS.ViewQuery.ViewQuery opViewQuery = new PowerCreator.LMS.ViewQuery.ViewQuery();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    private int theDayNumOfWeek = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        BinderWebClick();
    }
    private void BinderWebClick()
    {
        //访问统计
        //今日在线
        PowerCreator.LMS.Web.User.User opUser = new PowerCreator.LMS.Web.User.User();
        string search = "";
        lbl_UserToDayHistoryOnline.Text = opUser.QueryOnlineUserCount(search).ToString();
        lbl_UserRegistorCount.Text = opUser.Count(search).ToString();

        lbl_UserToDaCurrentyOnline.Text = opUser.QueryCurrentOnlineUser().ToString();
        search = string.Format("convert(varchar(12),OnlineuserLoginTime,112) = '{0}'", DateTime.Now.ToString("yyyyMMdd"));
        lbl_UserToDayOnline.Text = opUser.QueryOnlineUserCount(search).ToString();
        search = string.Format("convert(varchar(12),OnlineuserLoginTime,112) > '{0}' and convert(varchar(12),OnlineuserLoginTime,112) < '{1}'", DateTime.Now.AddDays(0 - theDayNumOfWeek).ToString("yyyyMMdd"), DateTime.Now.AddDays(8 - theDayNumOfWeek).ToString("yyyyMMdd"));
        lbl_UserToDayWeekOnline.Text = opUser.QueryOnlineUserCount(search).ToString();
    }
    private int getWeekNum()
    {
        int weeknum = 1;
        string dayofweek = DateTime.Now.DayOfWeek.ToString();
        switch (dayofweek)
        {
            case "Monday":
                weeknum = 1;
                break;
            case "星期一":
                weeknum = 1;
                break;
            case "Tuesday":
                weeknum = 2;
                break;
            case "星期二":
                weeknum = 2;
                break;
            case "Wednesday":
                weeknum = 3;
                break;
            case "星期三":
                weeknum = 3;
                break;
            case "Thursday":
                weeknum = 4;
                break;
            case "星期四":
                weeknum = 4;
                break;
            case "Friday":
                weeknum = 5;
                break;
            case "星期五":
                weeknum = 5;
                break;
            case "Saturday":
                weeknum = 6;
                break;
            case "星期六":
                weeknum = 6;
                break;
            case "Sunday":
                weeknum = 7;
                break;
            case "星期日":
                weeknum = 7;
                break;
            default:
                weeknum = 1;
                break;

        }
        return weeknum;
    }
}
